


import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.solidtrust.crawler.service.GanjiService;
import com.solidtrust.crawlers.Che168Sitemap;
import com.solidtrust.crawlers.GanjiSitemap;
import com.solidtrust.crawlers.RenrencheSitemap;

public class Start {

	private static final Logger log4j = Logger.getLogger(Start.class);
	
	public static void main(String[] args) throws Exception {
		//spring
		@SuppressWarnings("resource")
		ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:spring.xml");
//		RenrencheSitemap sitemap = (RenrencheSitemap)ctx.getBean("renrencheSitemap");
//		Che168Sitemap sitemap = (Che168Sitemap)ctx.getBean("che168Sitemap");
		GanjiSitemap sitemap = (GanjiSitemap)ctx.getBean("ganjiSitemap");
		log4j.info("------------------------------------------sitemap start");
		if(args.length > 0){
			sitemap.setInterval(Integer.parseInt(args[0]));
		}
		sitemap.start();
		log4j.info("------------------------------------------sitemap end");
		
//		PageSource page = new PageSource();
//		page.setUrl("https://www.renrenche.com/yc/ershouche/p43");
//		sitemap.eachPage(page, 1);
		
//		GanjiService gs = (GanjiService)ctx.getBean("ganjiService");
//		System.out.println(gs.getExactModel("大切诺基 4000", "大切诺基"));
//		System.out.println(gs.getExactModel("大切诺基 4000", "切诺基"));
//		System.out.println(gs.getExactModel("CTS-V 旅行版", "CTS"));
//		System.out.println(gs.getExactModel("CTS-V 旅行版", "CTS-V"));
//		System.out.println(gs.getExactModel("CTS Coupe", "CTS"));
	}
}
